<template>
	<view>
		<view class="uni-list">
			<radio-group @change="radioChange">
				<label class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in items" :key="item.value">
					<view>
						<radio :value="item.value" :checked="index === current" />
					</view>
					<view>{{item.name}}</view>
				</label>
			</radio-group>
		</view>
		<button type="primary" @click="editsex" class="btn">保存性别</button>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				items: [{
						value: '男',
						name: '男'
					},
					{
						value: '女',
						name: '女',
					},
					
				],
				current: 0
			}
		},
		methods: {
			radioChange(evt) {
				for (let i = 0; i < this.items.length; i++) {
					if (this.items[i].value === evt.detail.value) {
						this.current = i;
						break;
					}
				}
			},
			editsex(){
				var globaluser = this.getGlobalUser('globaluser')
				globaluser.sex = this.items[this.current].name
				uni.setStorageSync('globaluser',globaluser)
				uni.navigateBack({
					delta:1
				})
			}
		}
	}
</script>

<style>
	.uni-list-cell {
		justify-content: flex-start
	}
	.uni-list-cell-pd{
		display: flex;
		padding: 40upx;
		font-weight: 600;
	}
	.btn{
		margin: 0upx 40upx;
	}
</style>
